package com.elinkway.infinitemovies.async;

import android.content.Context;

import com.elinkway.infinitemovies.bean.RelationList;
import com.elinkway.infinitemovies.http.api.MoviesHttpApi;
import com.elinkway.infinitemovies.http.parser.RelationListParser;
import com.lvideo.http.bean.LVideoDataHull;

public class RequestRelationsTask extends MoviesHttpAsyncTask<RelationList>{

	public RequestRelationsTask(Context context) {
		super(context);
	}
	private String src;
	private String aid;
	private String cid;
	@Override
	public LVideoDataHull<RelationList> doInBackground() {
		return MoviesHttpApi.requestRelation(new RelationListParser(), src, cid, aid);
	}
	private RequestResultListener <RelationList> mListener;

    public void setParams(String src, String aid, String cid) {
    	this.src = src;
    	this.aid = aid;
    	this.cid = cid;
    }

	@Override
	public void onPostExecute(int updateId, RelationList result) {
		if(null != mListener) {
			mListener.onRequestSuccess(updateId, result);
			
		}
	}

	public RequestResultListener <RelationList> getListener() {
		return mListener;
	}

	@Override
	public void netNull() {
		super.netNull();
		if(null != mListener) {
			mListener.onRequestFailed();
		}
	}

	@Override
	public void netErr(int updateId, String errMsg) {
		super.netErr(updateId, errMsg);
		if(null != mListener) {
			mListener.onRequestFailed();
		}
	}

	@Override
	public void dataNull(int updateId, String errMsg) {
		super.dataNull(updateId, errMsg);
		if(null != mListener) {
			mListener.onRequestFailed();
		}
	}

	public void setListener(RequestResultListener <RelationList> mListener) {
		this.mListener = mListener;
	}

}
